-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support --exclude more than once on command line #11329
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, maybe config is parsing it as a string still?
dcc7f3b
to
3083adc
Compare
Yep - when I add it to
as
I added four integration tests that should help cover this case and fixed the issue. |
docs/source/config_file.rst
Outdated
@@ -197,9 +197,9 @@ section of the command line docs. | |||
|
|||
.. confval:: exclude | |||
|
|||
:type: regular expression | |||
:type: comma-separated list of regular expressions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this actually seems bad - because commas can appear in regular expressions. Perhaps we need another way to delimit multiple entries? Is there precedent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #10310 (comment) - I opted to go for newline separated list of regexes and updated the docs
The result is an "OR" of all the patterns provided. Should be fully backward compatible to existing folks. Fixes python#10310
3083adc
to
4dab5a7
Compare
Hiya - wanted to check in w/ the maintainers on this one again (no rush - just want to make sure it wasn't forgotten) |
Thanks, this is great! |
It would be awesome to get a release that contains this fix. |
python#11329 added support for nicer `exclude` lists TOML has a built-in list syntax, and it would be nice to use that for specifying lists for the `exclude` option. This change tries the ini-style first: if `exclude` is set to a multiline string, it will split that on newlines, otherwise it will assume it's a list.
python#11329 added support for nicer `exclude` lists TOML has a built-in list syntax, and it would be nice to use that for specifying lists for the `exclude` option. This change tries the ini-style first: if `exclude` is set to a multiline string, it will split that on newlines, otherwise it will assume it's a list.
For anyone following along at home, this does not appear to have made it into today's release of mypy 0.920. |
How do these get represented in |
@@ -124,6 +124,7 @@ def check_follow_imports(choice: str) -> str: | |||
'cache_dir': expand_path, | |||
'python_executable': expand_path, | |||
'strict': bool, | |||
'exclude': lambda s: [p.strip() for p in s.split('\n') if p.strip()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible root cause for #11825?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - seems likely. Good find. The config_parser uses very basic newlines to split apart different excludes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior is documented in the config_file.rst
- about multiple patterns in a newline separated manner.
Didn't realize that multiline excludes like this were an old pattern
Suggestion on what to do to fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't realize that multiline excludes like this were an old pattern
To be fair, I don't know if that was ever official. It was more of a work-around that folks discovered because they (probably like you) were desperately seeking a fix for #10310.
config_parser.py
is new to me, and I'm still trying to digest it. At a high level, I'm wondering if one can treat .toml
files differently? It looks like there's a mechanism to do that, but I'm still trying to figure out if it's sufficient for what I have in mind, i.e., in a .toml
file, if it's a string, just parse it as a single regex, but if it's an array, treat each item as its own regex? (Just thinking out loud here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking further, I think this might be as simple as appending the following here:
toml_config_types.update({
# …
'exclude': try_split,
})
UPDATE: Nope. No. That would still try to split strings along commas.
Dunno what testing looks like yet, though….
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I know you, you're probably ¾ done with a PR by now, but if you haven't started, I can take a stab….
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't started. Go for it!
Appreciate the compliment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at the details, but there's also this PR that was opened recently: #11746
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads-up @hauntsaninja! I don't think that one works. I'll comment there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially reverts python#11329 (with respect to `.ini` documentation). Modifies existing unit tests. Fixes python#11830.
Partially reverts #11329 (with respect to `.ini` documentation). Modifies existing unit tests. Fixes #11830. Co-authored-by: Matthew W <[email protected]>
Partially reverts #11329 (with respect to `.ini` documentation). Modifies existing unit tests. Fixes #11830. Co-authored-by: Matthew W <[email protected]>
The result is an "OR" of all the patterns provided. Should be fully backward compatible to existing folks. Fixes python#10310
Partially reverts python#11329 (with respect to `.ini` documentation). Modifies existing unit tests. Fixes python#11830. Co-authored-by: Matthew W <[email protected]>
Description
Support --exclude more than once on command line
The result is an "OR" of all the patterns provided.
Should be fully backward compatible to existing folks.
Fixes #10310
Test Plan
Added tests for the new behavior to
test_find_sources.py
. Also did a quick manual test to make sure command line arguments are working ok.